import { Global, Module } from '@nestjs/common';
import { RedisCacheService } from './redis/redis-cache.service';
import { VerificationCodeService } from './code/verification-code.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CodeEntity } from 'src/common/entities/code.entity';
import { VerificationCodeController } from './code/verification-code.controller';
import { QiniuModule } from './qiniu/qiniu.module';
import { ConfigModule, ConfigService } from '@nestjs/config';
// import { QQEmailModule } from './qq-email/email.module';
import * as path from 'path';
import { TXSmsModule } from './tx-sms/sms.module';
// import { RMQController } from './rmq/rmq.controller';
@Global()
@Module({
  imports: [
    QiniuModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => {
        return {
          ...config.get('qiniu'),
        };
      },
    }),
    TypeOrmModule.forFeature([CodeEntity]),
    // QQEmailModule.register({
    //   auth: {
    //     user: '1985931915@qq.com',
    //     pass: 'ebcueiujetmsedig',
    //   },
    //   from: 'aksu<1985931915@qq.com>',
    //   templateDir: path.join(
    //     process.cwd(),
    //     './src/component/qq-email/template',
    //   ), //这里就是你的ejs模板文件夹路径
    // }),
    TXSmsModule.register({
      secretId: 'AKIDyobO0PsBH9mBOceUdaKrCKFvNbb8TbVB',
      secretKey: 'UAdsumPoz0GJ8ileKk197sPl03sY1HKA',
      region: 'ap-shanghai',
      SmsSdkAppid: '1400811173',
      Sign: '阿克苏个人网',
    }),
  ], //注入实体，可注入多个实体，是数组
  controllers: [VerificationCodeController],
  providers: [RedisCacheService, VerificationCodeService],
  exports: [QiniuModule, RedisCacheService, VerificationCodeService],
})
export class ComponentModule {}
